package com.cm.log_process.log_common.reg;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Creator:郭兆鹏
 * Date:2019/12/23
 * 思路：手机号匹配正则
 */
public class BusinessRegexp {
    //日志内部手机号匹配正则
    private String phoneReg = "[\\D](86)?1[3,5,7,8][0-9]{9}[\\D]";
    private Pattern pattern = Pattern.compile(phoneReg);

    //手机号参数正则
    private String phoneParamReg = "^[1][3,5,7,8][0-9]{9}$";
    private Pattern phonePattern = Pattern.compile(phoneParamReg);

    public  String getPhoneReg() {
        return this.phoneReg;
    }

    public void setPhoneReg(String phoneReg) {
        this.phoneReg = phoneReg;
    }

    /**
     * 根据传入的数据以及文件类型进行正则判断是否包含
     * */
    public boolean testPhoneNum(String phoneNum){
        Matcher matcher = pattern.matcher(phoneNum);
        return matcher.find();
    }

    /*
    * 匹配输入的手机号参数
    * */
    public boolean testPhoneParam(String phoneParam){
        if(phoneParam.length()<11){
            return false;
        }
        Matcher matcher = phonePattern.matcher(phoneParam);
        return matcher.find();
    }
}
